package com.kingyea.mobilepolice.organizationcopy.service.impl;

import com.kingyea.mobilepolice.organizationcopy.bean.OrganizationCopy;
import com.kingyea.mobilepolice.organizationcopy.bean.OrganizationCopyCondition;
import com.kingyea.mobilepolice.organizationcopy.dao.OrganizationCopyMapper;
import com.kingyea.mobilepolice.organizationcopy.service.OrganizationCopyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Mr.Lin
 * @version v1.0.0
 * @description OrganizationCopy 实现类
 * @date Created in 2018-03-30 15:30:32
 */
@Service
@Transactional
public class OrganizationCopyServiceImpl implements OrganizationCopyService {

    private static final Logger LOGGER = LoggerFactory.getLogger(OrganizationCopyServiceImpl.class);

    @Resource
    private OrganizationCopyMapper organizationCopyMapper;

    /**
     * 通过ID查找对象
     *
     * @param orgId
     * @return
     */
    @Override
    public OrganizationCopy getById(Integer orgId) throws Exception {
        return this.organizationCopyMapper.getById(orgId);
    }

    /**
     * 列表
     *
     * @param
     * @return
     */
    @Override
    public List<OrganizationCopy> search(OrganizationCopyCondition condition) throws Exception {
        List<OrganizationCopy> list = organizationCopyMapper.search(condition);
        return list;
    }

    /**
     * 删除
     *
     * @param orgId
     * @return
     */
    @Override
    public int deleteById(Integer orgId) throws Exception {
        organizationCopyMapper.deleteById(orgId);
        return 1;
    }

    /**
     * 保存
     *
     * @param organizationCopy
     * @return
     */
    @Override
    public OrganizationCopy save(OrganizationCopy organizationCopy) throws Exception {
        try {
            organizationCopyMapper.save(organizationCopy);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return organizationCopy;
    }

    /**
     * 更新
     *
     * @param organizationCopy
     * @return
     */
    @Override
    public OrganizationCopy update(OrganizationCopy organizationCopy) throws Exception {
        try {
            organizationCopyMapper.update(organizationCopy);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return organizationCopy;
    }


}
